﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GBlog.Core.Entities;

namespace GBlog.Core.Mapping
{
    public class CommentMap : MapBase<Comment, int>
    {
        public CommentMap()
        {
            ToTable("Core_Comment");
            RegisterID();
            HasRequired(t => t.Post).WithMany(t => t.Comments).HasForeignKey(t => t.PostID).WillCascadeOnDelete(false);
            Property(t => t.Name).HasMaxLength(32);
            Property(t => t.Content).IsRequired().HasMaxLength(400);
            Property(t => t.Email).HasMaxLength(64);
            Property(t => t.Website);
            Property(t => t.IsUser).IsRequired();
            HasOptional(t => t.User).WithMany(t => t.Comments).HasForeignKey(t => t.PostID).WillCascadeOnDelete(false);            
            RegisterDefault();
        }
    }
}
